//
// Created by cheng on 2021/02/01.
//
#include "Sort.h"

void InsertionSort(int *array, int length) {
    if (length <= 1)
        return;
    int temp, j;
    for (int i = 1; i < length; ++i) {
        temp = array[i];
        j = i-1;
        while (j >= 0 && array[j] > temp) {
            array[j + 1] = array[j];
            --j;
        }
        array[j + 1] = temp;
        Sort::printArray(array, length);
    }
}